//
// Created by xumy on 2021/9/9.
// 冒泡排序:每次比较相邻的两个数的大小关系，然后调整位置，把大的数往后排
//
#include "iostream"

using namespace std;

void bubble_sort(int arr[], int len) {
    int i, j, temp;

    for (i = 0; i < len - 1; ++i) {
        for (j = 0; j < len - 1 - i; ++j) {
            if (arr[j] > arr[j+1]){
                temp = arr[j];
                arr[j] = arr[j+1];
                arr[j+1] = temp;
            }
        }
    }

}

int main() {

    int arrs[] = {3, 24, 5, 78, -1, 2304, 8, 1};
    int leng = sizeof(arrs) / sizeof(arrs[0]);

    bubble_sort(arrs, leng);

    for (int i = 0; i < leng; ++i) {
        cout << arrs[i] << " ";

    }

    return 0;
}
